# Maintainer: Marcelo Duarte https://github.com/marcelotduarte

_realname=cx-logging
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.1.0
pkgrel=2
pkgdesc="Python and C interfaces for logging (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
license=('PSF')
url="https://github.com/anthony-tuininga/cx_Logging"
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools" "${MINGW_PACKAGE_PREFIX}-cc")
options=('staticlibs' 'strip' '!debug')
source=(cx_Logging-${pkgver}.tar.gz::https://pypi.io/packages/source/c/cx_Logging/cx_Logging-${pkgver}.tar.gz
        0001-setup-remove-compiler-option.patch)
sha256sums=('8a06834d8527aa904a68b25c9c1a5fa09f0dfdc94dbd9f86b81cd8d2f7a0e487'
            'b2556f8f96f32743b70e775b5a08c7128df6c4757ef49f11b054f0688d9b6dd2')

prepare() {
  cd "${srcdir}/cx_Logging-${pkgver}"

  # For clang
  if [[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]]; then
    patch -p1 -i "${srcdir}/0001-setup-remove-compiler-option.patch"
  fi

  cd "${srcdir}"
  rm -Rf python-${_realname}-${CARCH}
  cp -a cx_Logging-${pkgver} python-${_realname}-${CARCH}
}

package() {
  local _mingw_prefix=$(cygpath -wm ${MINGW_PREFIX})
  cd python-${_realname}-${CARCH}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1
}
